package Vista;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import Controlador.Sistema;

public class AltaTarjeta extends javax.swing.JFrame {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JLabel jLabel1;
	private JLabel jLabel2;
	private JLabel jLabel3;
	private JButton guardar;
	private JTextField limite;
	private JTextField numero;
	private JTextField dni;
	private Sistema sistema;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				AltaTarjeta inst = new AltaTarjeta();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public AltaTarjeta() {
		super();
		sistema = new Sistema();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				jLabel1 = new JLabel();
				getContentPane().add(jLabel1);
				jLabel1.setText("Dni:");
				jLabel1.setBounds(12, 20, 21, 16);
			}
			{
				jLabel2 = new JLabel();
				getContentPane().add(jLabel2);
				jLabel2.setText("Numero:");
				jLabel2.setBounds(12, 61, 81, 16);
			}
			{
				jLabel3 = new JLabel();
				getContentPane().add(jLabel3);
				jLabel3.setText("Limite:");
				jLabel3.setBounds(12, 101, 54, 16);
			}
			{
				dni = new JTextField();
				getContentPane().add(dni);
				dni.setBounds(93, 6, 148, 23);
			}
			{
				numero = new JTextField();
				getContentPane().add(numero);
				numero.setBounds(93, 54, 148, 23);
			}
			{
				limite = new JTextField();
				getContentPane().add(limite);
				limite.setBounds(93, 98, 148, 23);
			}
			{
				guardar = new JButton();
				getContentPane().add(guardar);
				guardar.setText("Guardar");
				guardar.setBounds(264, 213, 82, 23);
				guardar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						sistema.crearTarjeta(dni.getText(), Integer.parseInt(numero.getText()), Integer.parseInt(limite.getText()));
					}
				});
			}
			pack();
			setSize(400, 300);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
